package cn.itcast.order.contrller;


import cn.itcast.hmall.dto.common.ResultDTO;
import cn.itcast.hmall.dto.order.OrderReqDTO;
import cn.itcast.hmall.pojo.order.Order;
import cn.itcast.order.service.ServiceOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController

public class ContrllerOrder {
    @Autowired
    ServiceOrder serviceOrder;

    @PostMapping("/order")
    public void orderReqDTO(@RequestBody OrderReqDTO orderReqDTO) {
        serviceOrder.createOrder(orderReqDTO);
    }

    @GetMapping("/order/{orderId}")
    public Order selelctpayorder(@PathVariable String orderId) {
        return serviceOrder.getById(orderId);

    }

    @PutMapping("/pay/{orderId}")
    public ResultDTO payorder(@PathVariable long orderid, Map<String, String> key) {
        return serviceOrder.payorders(orderid,key);
    }
}
